<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * -----------------------------------------------------
 *
 * manage Member
 *
 * @package     manage
 * @subpackage  
 * @category    Member -  会员
 * @author      ChenFu
 * @since       2015-6-17 version 1.0
 * -----------------------------------------------------    
 */
class Member extends CI_Controller{
	public function __construct(){
		parent::__construct();
		$this->load->helper(array('form', 'url'));
	  	$this->load->library('form_validation'); // 表单验证类
		$this->load->model('member_model');      // 加载会员模型
		check_login(); // 检查是否登录
	}

	/**
	 * 会员列表
	 * @return [type] [list]
	 */
	public function index()
	{
		$total = $this->member_model->get_num_rows();
		if($total != 0){
			// 加载分页类
			$arr = array('page_total_num' => $total,'every_page_num'=>10,'page_url_name'=>'page_id');
			$this->load->library('page',$arr);
			$data['pager']	  = $this->page->pages_all();
			$data['arr'] 	  = $this->member_model->get_all_data_and_page($this->page->limit);

		}else{
			$data['error'] = '暂无会员!';
		}
		$this->load->view('admin/member/index',$data);
	}



	/**
	 * 删除会员
	 */
	public function delete()
	{
		if(!empty($_GET['id']) && intval($_GET['id'])){
			if($this->member_model->delete($_GET['id'])){
				die('ok');
			}else{
				die('no');
			}
		}else{
			die('error_1');
		}
	}

}